#include <avz.h>

using namespace AvZ;

void Script()
{
    // OpenMultipleEffective('Q', AvZ::MAIN_UI_OR_FIGHT_UI); // 多次生效
    WriteMemory<unsigned short>(0xd231, 0x0041a68d); // 开雾
    SetAdvancedPauseKey('Z');                        // 按 Z 键控制高级暂停

    SetZombies({
        ZOMBIE,
        POLE_VAULTING_ZOMBIE,
        FOOTBALL_ZOMBIE,
        DANCING_ZOMBIE,
        ZOMBONI,
        JACK_IN_THE_BOX_ZOMBIE,
        DIGGER_ZOMBIE,
        POGO_ZOMBIE,
        BUNGEE_ZOMBIE,
        LADDER_ZOMBIE,
        CATAPULT_ZOMBIE,
        GARGANTUAR,
        GIGA_GARGANTUAR,
        DOLPHIN_RIDER_ZOMBIE,
        SNORKEL_ZOMBIE,
    });

    SelectCards({
        ICE_SHROOM,
        M_ICE_SHROOM,
        JALAPENO,
        DOOM_SHROOM,
        CHERRY_BOMB,
        PUMPKIN,
        PUFF_SHROOM,
        SUN_SHROOM,
        SCAREDY_SHROOM,
        FLOWER_POT,
    });

    SetTime(-599, 1);
    pao_operator.autoGetPaoList();

    plant_fixer.start(PUMPKIN);
    plant_fixer.resetFixHp(4000 * 1 / 3);

    for (auto wave : {1, 3, 11, 13})
    {
        // w1,3,11,13
        // PPSSDD 601
        SetTime(293 - 373, wave);
        pao_operator.pao({{2, 9}, {2, 9}, {5, 9}, {5, 9}});
        Delay(110);
        pao_operator.pao({{1, 8.9725}, {5, 8.9725}});
    }

    for (auto wave : {7, 17})
    {
        // w7,17
        // PPDDDD 601
        SetTime(227 - 373, wave);
        pao_operator.pao({{2, 9}, {5, 9}});
        Delay(107);
        pao_operator.pao({{1, 9}, {5, 9}});
        Delay(107);
        pao_operator.pao({{1, 8.8725}, {5, 8.8725}});
    }

    SetTime(293 - 373, 9);
    // w9
    // PPSSDD-PP 601
    pao_operator.pao({{2, 9}, {2, 9}, {5, 9}, {5, 9}});
    Delay(107);
    pao_operator.pao({{1, 8.9725}, {5, 8.9725}});
    SetTime(1117 - 373);
    pao_operator.pao({{2, 9}, {5, 9}});

    // w19
    // PPSADD+p-PP 601
    SetTime(293 - 100, 19);
    Card(CHERRY_BOMB, 6, 9);
    SetTime(293 - 373);
    pao_operator.pao({{2, 9}, {2, 9}, {5, 9}, {1, 1}});
    Delay(107);
    pao_operator.pao({{1, 8.9725}, {5, 8.9725}});
    SetTime(1117 - 373);
    pao_operator.pao({{2, 9}, {5, 9}});

    for (auto wave : {2, 4, 8, 12, 14, 18})
    {
        // w2,4,8,12,14,18
        // PPDD精准之舞 601
        SetTime(359 - 373, wave);
        pao_operator.pao({{2, 9}, {5, 9}});
        Delay(107);
        pao_operator.pao({{1, 7.8125}, {5, 7.8125}});
        if (wave == 10)
        {
            SetTime(359 - 100);
            Card(CHERRY_BOMB, 5, 9);
        }
    }

    SetTime(359 - 373, 10);
    // w10
    // PD精准之舞/PAD 601
    pao_operator.pao(2, 9);
    Delay(107);
    pao_operator.pao(1, 7.8125);

    SetTime(318 - 373);
    pao_operator.pao(5, 9);
    Delay(107);
    pao_operator.pao(5, 8.9725);
    SetTime(318 - 100);
    Card(CHERRY_BOMB, 5, 9);

    // w5,15
    // NA'I3 601
    SetTime(318 - 100, 5);
    Card({{DOOM_SHROOM, 2, 9}, {JALAPENO, 6, 9}});
    SetTime(318 + 105 - 100);
    Card(ICE_SHROOM, 4, 9);

    SetTime(318 - 100, 15);
    Card({{DOOM_SHROOM, 5, 9}, {JALAPENO, 1, 9}});
    SetTime(318 + 105 - 100);
    Card(ICE_SHROOM, 4, 9);

    for (auto wave : {6, 16})
    {
        // w6,16
        // PPSSI2 601
        SetTime(318 - 373, wave);
        pao_operator.pao({{2, 9}, {5, 9}});
        pao_operator.recoverPao({{2, 9}, {5, 9}});
        SetTime(318 - 100 - 319);
        Card(M_ICE_SHROOM, 4, 9);
    }

    // w20
    // PPDDDD-PP
    SetTime(-150, 20);
    pao_operator.pao(4, 7.5875);
    SetTime(318 - 373);
    pao_operator.pao({{2, 9}, {5, 9}});
    SetTime(409 - 373 + 66 - 107);
    pao_operator.pao({{1, 8.9725}, {5, 8.9725}});
    SetTime(409 - 373 + 66);
    pao_operator.pao({{1, 8.9725}, {5, 8.9725}});
    SetTime(5500 - 373);
    pao_operator.pao({{2, 9}, {5, 9}});
}